<#assign tit><#if _oper='add'>新增<#else>修改</#if>K-Yoga课程</#assign>
<@page.html title=tit>
<script type="text/javascript">
  <#assign weekList=["日","一","二","三","四","五","六"]/>
  var sl_days = '<select><#if weekList??><#list weekList as t><option value="${t_index+1}">星期${t!}</option></#list></#if></select>';
  var sl_hhmm = '<select><#list 8..22 as h><option value="${h}">${h}</option></#list></select><span>:</span><select><#list 0..59 as m><#if m%5=0><option value="${m}">${m}</option></#if></#list></select>';
  var ss_del = '<img src="${_appPath!}/images/del.png" onclick="deli(this);" style="cursor:pointer;"/>';

  function deli(e) {
    var tr = e.parentNode.parentNode;
    var aid = tr.getAttribute("aid");
    if(aid)
      tr.style.display = "none";
    else
      tr.parentNode.deleteRow(tr.rowIndex);
  }
  function addt() {
    var tb = getEl("tb_time");
    if(!tb) return;
    var tr = tb.insertRow(-1);
    tr.className = (tb.rows.length%2?"line1":"line2");
    var td = tr.insertCell(-1);
    td.innerHTML = sl_days;
    td = tr.insertCell(-1);
    td.innerHTML = sl_hhmm;
    td = tr.insertCell(-1);
    td.innerHTML = ss_del;
  }

  function save(fm) {
    if(!dotbd(fm.times)) return false;
    return post(fm);
  }
  function dotbd(ipt) {
    var tb = getEl("tb_time");
    if(!tb) return false;
    var i, j, ww, hh, mm, tr, arr = [];
    for(j=1; j<tb.rows.length; j++) {
      tr = tb.rows[j];
      ww = tr.cells[0].firstChild.value;
      hh = tr.cells[1].childNodes[0].value;
      mm = tr.cells[1].childNodes[2].value;

      arr.push(ww+","+(hh.length<2?"0":"")+hh+":"+(mm.length<2?"0":"")+mm);
    }
    ipt.value = arr.join("|");
    return true;
  }
</script>
<div style="width:500px;">

  <form id="fm_input" method="post" action="_addm" onsubmit="return save(this);">
    <input type="hidden" name="times" value="">
    <div class="kbox">
      <table class="input">
        <tr>
          <th width="25%">课程</th>
          <td width="75%"><select name="ptCode" req="课程"><#if itemList??><#list itemList as t><option value="${t.code}"<#if table.ptCode?? && table.ptCode=t.code> selected</#if>>${t.code} - ${t.chName}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>教练</th>
          <td><select name="coachCode" req="教练"><#if coachList??><#list coachList as t><option value="${t.code}"<#if table.coachCode?? && table.coachCode=t.code> selected</#if>>${t.code} - ${t.chName}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>教室</th>
          <td><select name="roomCode" req="教练"><#if roomList??><#list roomList as t><option value="${t.code}"<#if table.roomCode?? && table.roomCode=t.code> selected</#if>>${t.code} - ${t.chName}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>人数</th>
          <td><input type="text" name="personMax" value="${table.personMax!}" req="人数" size="8" maxlength="4"></td>
        </tr>
        <tr>
          <th>月份</th>
          <td><select name="month"><#if monthList??><#list monthList as t><option value="${t}">${t}</option></#list></#if></select></td>
        </tr>
        <tr>
          <th>时间</th>
          <td>
            <table id="tb_time" class="list" style="width:250px;">
              <tr>
                <th style="height:30px; text-align:center;" width="35%">日期</th>
                <th style="height:30px; text-align:center;" width="55%">时间</th>
                <th style="height:30px; text-align:center;" width="10%"></th>
              </tr>
            </table>
            <div><a href="javascript:addt();" class="addline">增加一行</a></div>
          </td>
        </tr>
      </table>
    </div>
    <div class="button"><input type="submit" value="保 存"></div>
  </form>
</div>
</@page.html>